using System;
using Microsoft.Xna.Framework;

namespace Rocuna.Core.Extensions
{
    /// <summary>
    /// Extentions for the rocuna game class.
    /// </summary>
    public static class GameExtensions
    {
        /// <summary>
        /// Gets the service by type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self">The self.</param>
        /// <returns></returns>
        public static T GetService<T>(this Game self) where T : class
        {
            return self.Services.GetService(typeof(T)) as T;
        }

        /// <summary>
        /// Gets the service.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self">The self.</param>
        /// <param name="typeToSearch">The type to search.</param>
        /// <returns></returns>
        public static T GetService<T>(this Game self, Type typeToSearch) where T : class
        {
            return self.Services.GetService(typeToSearch) as T;
        }
    }
}